3.73 \(\int \frac{A+B \tan (e+f x)+C \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx\)

Optimal. Leaf size=99 \[ \frac{\left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d f \left (c^2+d^2\right )}-\frac{(B c-d (A-C)) \log (\cos (e+f x))}{f \left (c^2+d^2\right )}+\frac{x (A c+B d-c C)}{c^2+d^2} \]

[Out]

((A*c - c*C + B*d)*x)/(c^2 + d^2) - ((B*c - (A - C)*d)*Log[Cos[e + f*x]])/((c^2 + d^2)*f) + ((c^2*C - B*c*d +
A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)*f)

________________________________________________________________________________________

Rubi [A]  time = 0.097683, antiderivative size = 99, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 4, integrand size = 33, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.121, Rules used = {3626, 3617, 31, 3475} \[ \frac{\left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d f \left (c^2+d^2\right )}-\frac{(B c-d (A-C)) \log (\cos (e+f x))}{f \left (c^2+d^2\right )}+\frac{x (A c+B d-c C)}{c^2+d^2} \]

Antiderivative was successfully verified.

[In]

Int[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x]),x]

[Out]

((A*c - c*C + B*d)*x)/(c^2 + d^2) - ((B*c - (A - C)*d)*Log[Cos[e + f*x]])/((c^2 + d^2)*f) + ((c^2*C - B*c*d +
A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)*f)

Rule 3626

Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/((a_.) + (b_.)*tan[(e_.) + (f_.)*
(x_)]), x_Symbol] :> Simp[((a*A + b*B - a*C)*x)/(a^2 + b^2), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2), I
nt[(1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Dist[(A*b - a*B - b*C)/(a^2 + b^2), Int[Tan[e + f*x], x
], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a
*B - b*C, 0]

Rule 3617

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[
A/(b*f), Subst[Int[(a + x)^m, x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]

Rule 31

Int[((a_) + (b_.)*(x_))^(-1), x_Symbol] :> Simp[Log[RemoveContent[a + b*x, x]]/b, x] /; FreeQ[{a, b}, x]

Rule 3475

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps

\begin{align*} \int \frac{A+B \tan (e+f x)+C \tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx &=\frac{(A c-c C+B d) x}{c^2+d^2}-\frac{(-B c+A d-C d) \int \tan (e+f x) \, dx}{c^2+d^2}+\frac{\left (c^2 C-B c d+A d^2\right ) \int \frac{1+\tan ^2(e+f x)}{c+d \tan (e+f x)} \, dx}{c^2+d^2}\\ &=\frac{(A c-c C+B d) x}{c^2+d^2}-\frac{(B c-(A-C) d) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac{\left (c^2 C-B c d+A d^2\right ) \operatorname{Subst}\left (\int \frac{1}{c+x} \, dx,x,d \tan (e+f x)\right )}{d \left (c^2+d^2\right ) f}\\ &=\frac{(A c-c C+B d) x}{c^2+d^2}-\frac{(B c-(A-C) d) \log (\cos (e+f x))}{\left (c^2+d^2\right ) f}+\frac{\left (c^2 C-B c d+A d^2\right ) \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right ) f}\\ \end{align*}

Mathematica [C]  time = 0.213477, size = 117, normalized size = 1.18 \[ \frac{\frac{2 \left (A d^2-B c d+c^2 C\right ) \log (c+d \tan (e+f x))}{d \left (c^2+d^2\right )}+\frac{(-i A+B+i C) \log (-\tan (e+f x)+i)}{c+i d}+\frac{(i A+B-i C) \log (\tan (e+f x)+i)}{c-i d}}{2 f} \]

Antiderivative was successfully verified.

[In]

Integrate[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x]),x]

[Out]

((((-I)*A + B + I*C)*Log[I - Tan[e + f*x]])/(c + I*d) + ((I*A + B - I*C)*Log[I + Tan[e + f*x]])/(c - I*d) + (2
*(c^2*C - B*c*d + A*d^2)*Log[c + d*Tan[e + f*x]])/(d*(c^2 + d^2)))/(2*f)

________________________________________________________________________________________

Maple [B]  time = 0.037, size = 234, normalized size = 2.4 \begin{align*} -{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) Ad}{2\,f \left ({c}^{2}+{d}^{2} \right ) }}+{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) Bc}{2\,f \left ({c}^{2}+{d}^{2} \right ) }}+{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) Cd}{2\,f \left ({c}^{2}+{d}^{2} \right ) }}+{\frac{A\arctan \left ( \tan \left ( fx+e \right ) \right ) c}{f \left ({c}^{2}+{d}^{2} \right ) }}+{\frac{B\arctan \left ( \tan \left ( fx+e \right ) \right ) d}{f \left ({c}^{2}+{d}^{2} \right ) }}-{\frac{C\arctan \left ( \tan \left ( fx+e \right ) \right ) c}{f \left ({c}^{2}+{d}^{2} \right ) }}+{\frac{d\ln \left ( c+d\tan \left ( fx+e \right ) \right ) A}{f \left ({c}^{2}+{d}^{2} \right ) }}-{\frac{\ln \left ( c+d\tan \left ( fx+e \right ) \right ) Bc}{f \left ({c}^{2}+{d}^{2} \right ) }}+{\frac{\ln \left ( c+d\tan \left ( fx+e \right ) \right ){c}^{2}C}{f \left ({c}^{2}+{d}^{2} \right ) d}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x)

[Out]

-1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*A*d+1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)^2)*B*c+1/2/f/(c^2+d^2)*ln(1+tan(f*x+e)
^2)*C*d+1/f/(c^2+d^2)*A*arctan(tan(f*x+e))*c+1/f/(c^2+d^2)*B*arctan(tan(f*x+e))*d-1/f/(c^2+d^2)*C*arctan(tan(f
*x+e))*c+1/f/(c^2+d^2)*d*ln(c+d*tan(f*x+e))*A-1/f/(c^2+d^2)*ln(c+d*tan(f*x+e))*B*c+1/f/(c^2+d^2)/d*ln(c+d*tan(
f*x+e))*c^2*C

________________________________________________________________________________________

Maxima [A]  time = 1.45554, size = 143, normalized size = 1.44 \begin{align*} \frac{\frac{2 \,{\left ({\left (A - C\right )} c + B d\right )}{\left (f x + e\right )}}{c^{2} + d^{2}} + \frac{2 \,{\left (C c^{2} - B c d + A d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{2} d + d^{3}} + \frac{{\left (B c -{\left (A - C\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}}}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="maxima")

[Out]

1/2*(2*((A - C)*c + B*d)*(f*x + e)/(c^2 + d^2) + 2*(C*c^2 - B*c*d + A*d^2)*log(d*tan(f*x + e) + c)/(c^2*d + d^
3) + (B*c - (A - C)*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2))/f

________________________________________________________________________________________

Fricas [A]  time = 1.22239, size = 269, normalized size = 2.72 \begin{align*} \frac{2 \,{\left ({\left (A - C\right )} c d + B d^{2}\right )} f x +{\left (C c^{2} - B c d + A d^{2}\right )} \log \left (\frac{d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) -{\left (C c^{2} + C d^{2}\right )} \log \left (\frac{1}{\tan \left (f x + e\right )^{2} + 1}\right )}{2 \,{\left (c^{2} d + d^{3}\right )} f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/2*(2*((A - C)*c*d + B*d^2)*f*x + (C*c^2 - B*c*d + A*d^2)*log((d^2*tan(f*x + e)^2 + 2*c*d*tan(f*x + e) + c^2)
/(tan(f*x + e)^2 + 1)) - (C*c^2 + C*d^2)*log(1/(tan(f*x + e)^2 + 1)))/((c^2*d + d^3)*f)

________________________________________________________________________________________

Sympy [A]  time = 14.0031, size = 966, normalized size = 9.76 \begin{align*} \text{result too large to display} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e)),x)

[Out]

Piecewise((zoo*x*(A + B*tan(e) + C*tan(e)**2)/tan(e), Eq(c, 0) & Eq(d, 0) & Eq(f, 0)), ((A*x + B*log(tan(e + f
*x)**2 + 1)/(2*f) - C*x + C*tan(e + f*x)/f)/c, Eq(d, 0)), (-I*A*f*x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*
f) - A*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*A/(-2*d*f*tan(e + f*x) + 2*I*d*f) - B*f*x*tan(e + f*x)/(-2*d*f*
tan(e + f*x) + 2*I*d*f) + I*B*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) + B/(-2*d*f*tan(e + f*x) + 2*I*d*f) - I*C*f*
x*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) - C*f*x/(-2*d*f*tan(e + f*x) + 2*I*d*f) - C*log(tan(e + f*x)**2
 + 1)*tan(e + f*x)/(-2*d*f*tan(e + f*x) + 2*I*d*f) + I*C*log(tan(e + f*x)**2 + 1)/(-2*d*f*tan(e + f*x) + 2*I*d
*f) + I*C/(-2*d*f*tan(e + f*x) + 2*I*d*f), Eq(c, -I*d)), (-I*A*f*x*tan(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f)
 + A*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) - I*A/(2*d*f*tan(e + f*x) + 2*I*d*f) + B*f*x*tan(e + f*x)/(2*d*f*tan(e
 + f*x) + 2*I*d*f) + I*B*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) - B/(2*d*f*tan(e + f*x) + 2*I*d*f) - I*C*f*x*tan(e
 + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + C*f*x/(2*d*f*tan(e + f*x) + 2*I*d*f) + C*log(tan(e + f*x)**2 + 1)*tan
(e + f*x)/(2*d*f*tan(e + f*x) + 2*I*d*f) + I*C*log(tan(e + f*x)**2 + 1)/(2*d*f*tan(e + f*x) + 2*I*d*f) + I*C/(
2*d*f*tan(e + f*x) + 2*I*d*f), Eq(c, I*d)), (x*(A + B*tan(e) + C*tan(e)**2)/(c + d*tan(e)), Eq(f, 0)), (2*A*c*
d*f*x/(2*c**2*d*f + 2*d**3*f) + 2*A*d**2*log(c/d + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) - A*d**2*log(tan(e +
f*x)**2 + 1)/(2*c**2*d*f + 2*d**3*f) - 2*B*c*d*log(c/d + tan(e + f*x))/(2*c**2*d*f + 2*d**3*f) + B*c*d*log(tan
(e + f*x)**2 + 1)/(2*c**2*d*f + 2*d**3*f) + 2*B*d**2*f*x/(2*c**2*d*f + 2*d**3*f) + 2*C*c**2*log(c/d + tan(e +
f*x))/(2*c**2*d*f + 2*d**3*f) - 2*C*c*d*f*x/(2*c**2*d*f + 2*d**3*f) + C*d**2*log(tan(e + f*x)**2 + 1)/(2*c**2*
d*f + 2*d**3*f), True))

________________________________________________________________________________________

Giac [A]  time = 1.62131, size = 147, normalized size = 1.48 \begin{align*} \frac{\frac{2 \,{\left (A c - C c + B d\right )}{\left (f x + e\right )}}{c^{2} + d^{2}} + \frac{{\left (B c - A d + C d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{2} + d^{2}} + \frac{2 \,{\left (C c^{2} - B c d + A d^{2}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{2} d + d^{3}}}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e)),x, algorithm="giac")

[Out]

1/2*(2*(A*c - C*c + B*d)*(f*x + e)/(c^2 + d^2) + (B*c - A*d + C*d)*log(tan(f*x + e)^2 + 1)/(c^2 + d^2) + 2*(C*
c^2 - B*c*d + A*d^2)*log(abs(d*tan(f*x + e) + c))/(c^2*d + d^3))/f